﻿#region Version Info
/* ========================================================================
* 【本类功能概述】
* 
* 作者：李荣楠
* 时间：2013-10-18 11:37:48
* 文件名：Utils
* .net版本：4.0 
* ========================================================================
*/
#endregion
using System;
using System.IO;
using System.Web;
using LCL.Config;

namespace LCL.Common
{
    /// <summary>
    /// 通用工具类
    /// </summary>
    public class Utils
    {
        #region 程序错误日志
        /// <summary>
        /// 记录程序错误日志
        /// </summary>
        /// <param name="str"></param>
        public static void WriteLogs(string str)
        {
            string IsWriteLog = UiConfig.IsWriteLog;
            StreamWriter writer;
            if (IsWriteLog == "1")
            {
                using (writer = new StreamWriter(HttpContext.Current.Request.PhysicalApplicationPath 
                    + @"logs\" + DateTime.Now.ToString("yyyyMMdd") + ".logs", true))
                {
                    writer.WriteLine("-----------------ICeX----------------");
                    writer.WriteLine(str);
                }
            }
        }
        #endregion

        #region 类型转化
        /// <summary>
        /// 将对象转换为Int32类型
        /// </summary>
        /// <param name="expression">要转换的字符串</param>
        /// <param name="defValue">缺省值</param>
        /// <returns>转换后的int类型结果</returns>
        public static int StrToInt(object expression, int defValue)
        {
            return TypeParse.StrToInt(expression, defValue);
        }
        #endregion

    }
}
